#define _CRT_SECURE_NO_WARNINGS 
#include <stdio.h>
int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	int que = (int)(m * 1.5), hum = 0, line = 0;
	int k[5000] = { 0 };
	int s[5000] = { 0 };
	int score[101] = { 0 };
	for (int i = 0; i < n; i++)
	{
		scanf("%d%d", &k[i], &s[i]);
		score[s[i]]++;
	}
	int z = 0;
	for (int i = 100;; i--)
	{
		int t = score[i];
		while (t--)
		{
			hum++;
			if (hum == que)
				line = i;
		}
		if (line == i)
			break;
	}
	printf("%d %d\n", line, hum);
	for (int i = 100; i >= line; i--)
	{
		int z = 0;
		int l[5000] = { 0 };
		for (int j = 0; j < score[i]; j++)
		{
			while (1)
			{
				if (s[z] == i)
				{
					l[j] = k[z];
					z++;
					break;
				}
				z++;
			}
		}
		if (score[i] > 0)
		{
			for (int q = 0; q < score[i] - 1; q++)
			{
				for (int w = 1; w < score[i] - q; w++)
				{
					if (l[w - 1] > l[w])
					{
						int tmp;
						tmp = l[w - 1];
						l[w - 1] = l[w];
						l[w] = tmp;
					}
				}
			}
			for (int q = 0; q < score[i]; q++)
			{
				printf("%d %d\n", l[q], i);
			}
		}
	}
	return 0;
}